﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using MusicApi.Models;

namespace MusicApi.Service
{
	public class SongServiceStub : ISongService
	{
		List<Song> testSongs;

		/* constructor creates 10 test songs instances */
		public SongServiceStub()
		{
			testSongs = new List<Song>(); /* instantiate the song list */
			addFiles(10); /* add 10 test files */
		}

		/* create some test songs */
		private void addFiles(int n)
		{
			for (int i = 0; i < n; i++)
			{
				Song s = new Song();
				
				s.filename = String.Format("c:\\mp3\\Bubbi -{0}Aldrei for eg sudur.mp3", i);
				s.guitarPartyId = "aldrei-for-eg-sudur";
				s.songId = i.ToString();
				s.title = String.Format("{0}Aldrei fór ég suður", i);
				s.genre = "General Rock";
				testSongs.Add(s);
			}

		}

		/* returns a song by song id */
		public IEnumerable<Song> GetSongByTitle(String title)
		{
			var songs = (from s in testSongs
						 where s.title == title
						 select s);
			return songs;
		}

		/* returns all songs */
		public IEnumerable<Song> GetAllSongs()
		{
			return testSongs.OrderBy(song => song.title); /* order by title */
		}

		/* return all songs by a single artist */
		public IEnumerable<Song> GetSongsByArtist(string artist)
		{
			var songs = (from s in testSongs
						 where s.artist == artist
						 select s);
			return songs;
		}


		public string GetMusicFileDir()
		{
			return @"C:\mp3";
		}


		public void HandleUploadFiles(string path)
		{
			throw new NotImplementedException();
		}


		public Song getSongByFilename(string filename)
		{
			throw new NotImplementedException();
		}

        #region ISongService Members


        public void HandleUpdatID3(Song filename)
        {
            throw new NotImplementedException();
        }

        #endregion

		IEnumerable<Song> ISongService.GetAllSongs()
		{
			throw new NotImplementedException();
		}

		IEnumerable<Song> ISongService.GetSongByTitle(string title)
		{
			throw new NotImplementedException();
		}

		IEnumerable<Song> ISongService.GetSongsByArtist(string artist)
		{
			throw new NotImplementedException();
		}

		string ISongService.GetMusicFileDir()
		{
			throw new NotImplementedException();
		}

		void ISongService.HandleUploadFiles(string path)
		{
			throw new NotImplementedException();
		}

		Song ISongService.getSongByFilename(string filename)
		{
			throw new NotImplementedException();
		}

		void ISongService.HandleUpdateID3(Song song)
		{
			throw new NotImplementedException();
		}
	}
}